翻訳と辞書
Words near each other
・ Local telephone service
・ Local television in the United Kingdom
・ Local ternary patterns
・ Local time (mathematics)
・ Local to Global Justice
・ Local trace formula
・ Local Transport Act 2008
・ Local transport bodies
・ Local transport plan
・ Local TV channels in Hungary
・ Local TV LLC
・ Local uniformization
・ Local union
・ Local United Network to Combat Hunger
・ Local usage details
Local variable
・ Local Vision TV
・ Local Void
・ Local volatility
・ Local Welfare Assistance Scheme
・ Local World
・ Local World Evolving Network Models
・ Local Yokel Media
・ Local zeta-function
・ Local-access television
・ Local-authority trading enterprise
・ Local-density approximation
・ Local-express lanes
・ Local-loop unbundling
・ Locala


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Local variable : ウィキペディア英語版
Local variable
In computer science, a local variable is a variable that is given ''local scope''. Local variable references in the function or block in which it is declared override the same variable name in the larger scope. In programming languages with only two levels of visibility, local variables are contrasted with global variables. On the other hand, many ALGOL-derived languages allow any number of nested levels of visibility, with private variables, functions, constants and types hidden within them, either by nested blocks or nested functions. Local variables are fundamental to procedural programming, and more generally modular programming: variables of local scope are used to avoid issues with side-effects that can occur with global variables.
Local variables may have a lexical or dynamic scope, though lexical (static) scoping is far more common. In lexical scoping (or lexical scope; also called static scoping or static scope), if a variable name's scope is a certain block, then its scope is the program text of the block definition: within that block's text, the variable name exists, and is bound to the variable's value, but outside that block's text, the variable name does not exist. By contrast, in dynamic scoping (or dynamic scope), if a variable name's scope is a certain block, then its scope is that block and all functions transitively called by that block (except when overridden again by another declaration); after the block ends, the variable name does not exist. Some languages, like Perl and Common Lisp, allow the programmer to choose static or dynamic scoping when defining or redefining a variable. Examples of languages that use dynamic scoping include Logo, Emacs lisp, and the shell languages bash, dash, and the MirBSD Korn shell (mksh)'s "local" declaration. Most other languages provide lexically scoped local variables.
In most languages, local variables are automatic variables stored on the call stack directly. This means that when a recursive function calls itself, local variables in each instance of the function are given distinct addresses. Hence variables of this scope can be declared, written to, and read, without any risk of side-effects to functions outside of the block in which they are declared.
Programming languages that employ ''call by value'' semantics provide a called subroutine with its own local copy of the arguments passed to it. In most languages, these local parameters are treated the same as other local variables within the subroutine. In contrast, ''call by reference'' and ''call by name'' semantics allow the parameters to act as aliases of the values passed as arguments, allowing the subroutine to modify variables outside its own scope.
==Static local variables==
A special type of local variable, called a ''static local,'' is available in many mainstream languages (including C/C++, Visual Basic, and VB.NET) which allows a value to be retained from one call of the function to another – it is a static variable with local scope. In this case, recursive calls to the function also have access to the (single, statically allocated) variable. In all of the above languages, static variables are declared as such with a special ''storage class'' keyword (e.g., static).
Static locals in global functions have the same lifetime as static global variables, because their value remains in memory for the life of the program,〔 (). In particular, see section 6.2.4 “Storage durations of objects”, page 32.〕 but have function scope (not global scope), as with automatic local variables.
This is distinct from other usages of the static keyword, which has several different meanings in various languages.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Local variable」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.